<@sp.pagehead shiroUserHelper.getCurrentShiroUser().parentSources />
<div class="panel panel-inverse" data-sortable-id="form-validation-1">
    <div class="panel-heading">
        <h4 class="panel-title">新增学生</h4>
    </div>
    <div class="panel-body">
        <form id="studentAddForm" name="studentAddForm" action="" method="post" class="form-horizontal form-bordered">
            <div class="form-group">
                <label class="control-label col-md-3 col-sm-3">学生姓名</label>
                <div class="col-md-7 col-sm-7">
                    <input type="text" id="stuName" class="form-control" name="stuName" value=""
                           placeholder="学生名称 2-10位" rangelength="2,10" required>
                </div>
            </div>
            <div class="form-group">
                <label class="control-label col-md-3 col-sm-3">学生学号</label>
                <div class="col-md-7 col-sm-7">
                    <input type="text" id="stuCode" class="form-control" name="stuCode" value=""
                           placeholder="学生学号 2-10位" rangelength="2,10" required>
                </div>
            </div>
            <div class="form-group">
                <label class="control-label col-md-3 col-sm-3">性别</label>
                <div class="col-md-7 col-sm-7">
                    <select id="stuGender" name="stuGender" class="form-control" required>
                        <option value="男" selected>男</option>
                        <option value="女">女</option>
                    </select>
                </div>
            </div>
            <div class="form-group">
                <label class="control-label col-md-3 col-sm-3">出生日期</label>
                <div class="col-md-7 col-sm-7">
                    <input type="date" id="stuBirthday" class="form-control" name="stuBirthday" value="" required>
                </div>
            </div>
            <div class="form-group">
                <label class="control-label col-md-3 col-sm-3">所在班级</label>
                <div class="col-md-7 col-sm-7">
                    <select id="clsId" class="form-control" name="clsId" required>
                        <#list clses as cls>
                        <option value="${cls.id}">${cls.clsName}</option>
                        </#list>
                    </select>
                </div>
            </div>

            <div class="form-group">
                <label class="control-label col-md-3 col-sm-3"></label>
                <div class="col-md-7 col-sm-7">
                    <button type="button" id="studentSubmitButton" class="btn btn-sm btn-success">提交</button>
                    <button type="button" class="btn btn-sm btn-default"
                            onclick="getData('${rc.contextPath}/student/query','${shiroUserHelper.getCurrentShiroUser().parentMenuSource.name}')">
                        返回
                    </button>
                </div>
            </div>
        </form>
    </div>
</div>
<script type="application/javascript">
    $(function () {
        $('#studentSubmitButton').click(function () {
            $('#studentAddForm').submit();
        })
        $('#studentAddForm').validate({
            rules: {
                name: {
                    byteRangeLength: [2, 20]
                }
            },
            messages: {
                studentName: {
                    rangelength: "长度为2-20位"
                }
            },
            errorPlacement: function (error, element) {
                error.appendTo(element.parent());
            },
            submitHandler: function () {
                postDataByForm('${rc.contextPath}/student/add', '${shiroUserHelper.getCurrentShiroUser().parentMenuSource.name}', 'studentAddForm');
            }
        })
    })
</script>

